package com.budwk.app.sqfw.services.customservice;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import com.budwk.app.common.component.DictComponent;
import com.budwk.app.common.config.AppException;
import com.budwk.app.oss.services.SysOssService;
import com.budwk.app.sqfw.bo.SqfwShopInfoDownloadBO;
import com.budwk.app.sqfw.component.CommunityStreetComponent;
import com.budwk.app.sqfw.constants.CommonConstants;
import com.budwk.app.sqfw.constants.CommonForAdminConstants;
import com.budwk.app.sqfw.dto.SqfwSummaryPdfExcelCollForAdminDTO;
import com.budwk.app.sqfw.models.PersonInfo;
import com.budwk.app.sqfw.models.Sqfw_cenSusPaper;
import com.budwk.app.sqfw.models.Sqfw_completeflow;
import com.budwk.app.sqfw.models.Sqfw_formSummary_new;
import com.budwk.app.sqfw.services.*;
import com.budwk.app.sqfw.services.common.SqfwCommonForAdminService;
import com.budwk.app.sqfw.services.common.SqfwCustomForAdminCommonService;
import com.budwk.app.sqfw.vo.*;
import com.budwk.app.sqfw.vo.dapingvo.SqfwDataStatisticInfoVO;
import com.budwk.app.sqfw.vo.povertymonitor.HouseHoldIncomeVO;
import com.budwk.app.sqfw.vo.povertymonitor.SqfwFamilyPropertyVO;
import com.budwk.app.sqfw.vo.povertymonitor.SqfwPovertyMonitorImportVO;
import com.budwk.app.sqfwDoc.bo.ExcelCreateConfig;
import com.budwk.app.sqfwDoc.codeGeneratorV2.fileParam.CompleteFlowExcelParamForController;
import com.budwk.app.sqfwDoc.codeGeneratorV2.generate.ResultOfExcelGenerator;
import com.budwk.app.sqfwV2.dto.PropagandaScreeningDTO;
import com.budwk.app.sqfwV2.dto.entity.SqfwFamilyProperty;
import com.budwk.app.sqfwV2.dto.entity.SqfwHouseholdRegistrationInfo;
import com.budwk.app.sqfwV2.dto.entity.SqfwShopsBaseInfo;
import com.budwk.app.sqfwV2.dto.povertyMonitoring.FamilyPropertyParamDataDTO;
import com.budwk.app.sqfwV2.dto.povertyMonitoring.PovertyAlleviationDTO;
import com.budwk.app.sqfwV2.enums.EntrepreneurHouseFileEnum;
import com.budwk.app.sqfwV2.enums.povertyMonitoring.FormingMaterialEnum;
import com.budwk.app.sqfwV2.service.entrepreneurShipHouse.EntrepreneurShipHouseService;
import com.budwk.app.sqfwV2.service.povertyMonitoring.PovertyMonitoringExcelService;
import com.budwk.app.sys.models.Sys_user;
import com.budwk.app.sys.services.SysLogService;
import com.budwk.app.sys.services.SysUserService;
import com.budwk.app.sys.vo.SysDictVO;
import com.budwk.app.util.adminUtils.CommonCheckUtils;
import com.budwk.app.util.poiUtils.CommonFormOfficeUtils;
import com.budwk.app.util.poiUtils.SqfwInfoDataEasyExcelListener;
import com.budwk.app.util.poiUtils.nutzBeanUtils.NutzIocUtils;
import com.budwk.starter.common.page.Pagination;
import com.budwk.starter.common.result.ResultCode;
import com.budwk.starter.security.utils.SecurityUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.dao.sql.Criteria;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.sql.SqlCallback;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.random.R;
import org.nutz.mvc.upload.TempFile;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;

/**
 * @program: dfxy-community
 * @description: 扶贫监测服务实现
 * @author: LJT
 * @create: 2024-06-17 10:11
 **/
@IocBean
@Slf4j
public class PovertyMonitorForAdminService {
    @Inject
    private SqfwFamilyPropertyService sqfwFamilyPropertyService;

    @Inject
    private SysLogService sysLogService;

    @Inject
    private SqfwHouseholdRegistrationInfoService sqfwHouseholdRegistrationInfoService;

    @Inject
    private PersonInfoService personInfoService;

    @Inject
    private SysUserService sysUserService;

    /**
     * @return
     */
    public HouseHoldIncomeVO getHouseHoldIncome(String year, String district) {
        if (StringUtils.isEmpty(year)) {
            throw new AppException("请输入年度参数！");
        }
        DateTime lastYear = DateUtil.offset(DateUtil.parseDate(year + "-01-01"), DateField.YEAR, -1);
        String lastYearStr = DateUtil.format(lastYear, "yyyy");
        // 统计本年数据
        int nowPeopleNum = 0;
        int lastPeopleNum = 0;
        HouseHoldIncomeVO houseHoldIncomeVO = new HouseHoldIncomeVO();
        BigDecimal oneQuarterIncome = new BigDecimal(0);
        BigDecimal twoQuarterIncome = new BigDecimal(0);
        BigDecimal threeQuarterIncome = new BigDecimal(0);
        BigDecimal fourQuarterIncome = new BigDecimal(0);
        BigDecimal lastOneQuarterIncome = new BigDecimal(0);
        BigDecimal lastTwoQuarterIncome = new BigDecimal(0);
        BigDecimal lastThreeQuarterIncome = new BigDecimal(0);
        BigDecimal lastFourQuarterIncome = new BigDecimal(0);
        BigDecimal nowHouseholdNetIncome = new BigDecimal(0);
        BigDecimal lastHouseholdNetIncome = new BigDecimal(0);
        List<SqfwFamilyProperty> nowFamilyProperties = new ArrayList<SqfwFamilyProperty>();
        if (StringUtils.isNotEmpty(district)) {
            // 查询户信息表
            Sql sql = Sqls.create("SELECT a.* FROM shequ.sqfw_household_registration_info b LEFT JOIN shequ.sqfw_family_property a ON a.household_id = b.house_number WHERE a.year IN ('" + year + "','" + lastYearStr + "') AND b.district = '" + district + "'");
            nowFamilyProperties = sqfwFamilyPropertyService.listEntity(sql);
        } else {
            StringBuffer sb = new StringBuffer();
            sb.append(" year IN ('").append(year).append("','").append(lastYearStr).append("')");
            nowFamilyProperties = sqfwFamilyPropertyService.query(Cnd.where(new Static(sb.toString())));
        }
        for (int i = 0; i < nowFamilyProperties.size(); i++) {
            FamilyPropertyParamDataDTO familyPropertyParamDataDTO = JSONUtil.toBean(nowFamilyProperties.get(i).getParamData(), FamilyPropertyParamDataDTO.class);
            if (year.equals(nowFamilyProperties.get(i).getYear())) {
                nowPeopleNum = nowPeopleNum + Integer.valueOf(nowFamilyProperties.get(i).getPeopleNumber());
                houseHoldIncomeVO.setNowTotalYearHouseHoldIncome(houseHoldIncomeVO.getNowTotalYearHouseHoldIncome().add(familyPropertyParamDataDTO.getTotalHouseHoldIncome()).setScale(2, RoundingMode.HALF_UP));
                if ("1".equals(nowFamilyProperties.get(i).getQuarter())) {
                    oneQuarterIncome = oneQuarterIncome.add(familyPropertyParamDataDTO.getTotalHouseHoldIncome()).setScale(2, RoundingMode.HALF_UP);
                } else if ("2".equals(nowFamilyProperties.get(i).getQuarter())) {
                    twoQuarterIncome = twoQuarterIncome.add(familyPropertyParamDataDTO.getTotalHouseHoldIncome()).setScale(2, RoundingMode.HALF_UP);
                } else if ("3".equals(nowFamilyProperties.get(i).getQuarter())) {
                    threeQuarterIncome = threeQuarterIncome.add(familyPropertyParamDataDTO.getTotalHouseHoldIncome()).setScale(2, RoundingMode.HALF_UP);
                } else if ("4".equals(nowFamilyProperties.get(i).getQuarter())) {
                    fourQuarterIncome = fourQuarterIncome.add(familyPropertyParamDataDTO.getTotalHouseHoldIncome()).setScale(2, RoundingMode.HALF_UP);
                }
                // 家庭总纯收入
                nowHouseholdNetIncome = nowHouseholdNetIncome.add(familyPropertyParamDataDTO.getHouseholdNetIncome()).setScale(2, RoundingMode.HALF_UP);
            } else if (lastYearStr.equals(nowFamilyProperties.get(i).getYear())) {
                lastPeopleNum = lastPeopleNum + Integer.valueOf(nowFamilyProperties.get(i).getPeopleNumber());
                houseHoldIncomeVO.setLastTotalYearHouseHoldIncome(houseHoldIncomeVO.getLastTotalYearHouseHoldIncome().add(familyPropertyParamDataDTO.getTotalHouseHoldIncome()).setScale(2, RoundingMode.HALF_UP));
                if ("1".equals(nowFamilyProperties.get(i).getQuarter())) {
                    lastOneQuarterIncome = lastOneQuarterIncome.add(familyPropertyParamDataDTO.getTotalHouseHoldIncome()).setScale(2, RoundingMode.HALF_UP);
                } else if ("2".equals(nowFamilyProperties.get(i).getQuarter())) {
                    lastTwoQuarterIncome = lastTwoQuarterIncome.add(familyPropertyParamDataDTO.getTotalHouseHoldIncome()).setScale(2, RoundingMode.HALF_UP);
                } else if ("3".equals(nowFamilyProperties.get(i).getQuarter())) {
                    lastThreeQuarterIncome = lastThreeQuarterIncome.add(familyPropertyParamDataDTO.getTotalHouseHoldIncome()).setScale(2, RoundingMode.HALF_UP);
                } else if ("4".equals(nowFamilyProperties.get(i).getQuarter())) {
                    lastFourQuarterIncome = lastFourQuarterIncome.add(familyPropertyParamDataDTO.getTotalHouseHoldIncome()).setScale(2, RoundingMode.HALF_UP);
                }
                // 家庭总纯收入
                lastHouseholdNetIncome = lastHouseholdNetIncome.add(familyPropertyParamDataDTO.getHouseholdNetIncome()).setScale(2, RoundingMode.HALF_UP);
            }
        }
        twoQuarterIncome.add(oneQuarterIncome);
        threeQuarterIncome.add(twoQuarterIncome);
        fourQuarterIncome.add(threeQuarterIncome);
        lastTwoQuarterIncome.add(lastOneQuarterIncome);
        lastThreeQuarterIncome.add(lastTwoQuarterIncome);
        lastFourQuarterIncome.add(lastThreeQuarterIncome);
        Map<String, BigDecimal> quarterIncomeMap = new HashMap<String, BigDecimal>();
        quarterIncomeMap.put("quarterIncome1", oneQuarterIncome);
        quarterIncomeMap.put("quarterIncome2", twoQuarterIncome);
        quarterIncomeMap.put("quarterIncome3", threeQuarterIncome);
        quarterIncomeMap.put("quarterIncome4", fourQuarterIncome);
        quarterIncomeMap.put("lastQuarterIncome1", lastOneQuarterIncome);
        quarterIncomeMap.put("lastQuarterIncome2", lastTwoQuarterIncome);
        quarterIncomeMap.put("lastQuarterIncome3", lastThreeQuarterIncome);
        quarterIncomeMap.put("lastQuarterIncome4", lastFourQuarterIncome);
        houseHoldIncomeVO.setQuarterHouseHoldIncome(quarterIncomeMap);
        houseHoldIncomeVO.setHouseNum(nowFamilyProperties.stream().filter(e -> year.equals(e.getYear())).count());
        double nowTotalIncome = 0.00;
        double lastTotalIncome = 0.00;
        if (0 != nowPeopleNum) {
            nowTotalIncome = nowHouseholdNetIncome.doubleValue() / nowPeopleNum;
        }
        if (0 != lastPeopleNum) {
            lastTotalIncome = lastHouseholdNetIncome.doubleValue() / lastPeopleNum;
        }
        houseHoldIncomeVO.setNowYearPersonAvgIncome(BigDecimal.valueOf(nowTotalIncome).setScale(2, RoundingMode.HALF_UP));
        houseHoldIncomeVO.setLastYearPersonAvgIncome(BigDecimal.valueOf(lastTotalIncome).setScale(2, RoundingMode.HALF_UP));
        if (0 == lastTotalIncome) {
            houseHoldIncomeVO.setChangePercent(0.00);
        } else {
            double percent = ((nowTotalIncome - lastTotalIncome) / lastTotalIncome) * 100;
            DecimalFormat df = new DecimalFormat("#.##");
            String formattedNumber = df.format(percent);
            houseHoldIncomeVO.setChangePercent(Double.parseDouble(formattedNumber));
        }
        return houseHoldIncomeVO;
    }

    /**
     * 导入户、人信息
     *
     * @param file
     * @return
     */
    public String importHousePersonInfo(TempFile houseFile, TempFile personFile, String district) {
        if (null == houseFile || null == personFile) {
            throw new AppException("上传文件为空！");
        }
        String result = "";
        // 导入户信息
        result = importHouseInfo(houseFile, district);
        // 导入人员信息
        result = result + importPersonInfo(personFile, district);
        return result;
    }

    /**
     * 导入户信息
     *
     * @param file
     * @return
     */
    private String importHouseInfo(TempFile file, String district) {
        if (file.getSize() <= 0) {
            return "户信息文件不能为空！";
        }
        if (!file.getFile().getName().endsWith(".xlsx")) {
            return "户信息文件格式不正确！";
        }
        String resStr = "";
        List<SqfwHouseholdRegistrationInfo> houseUpdateLog = new ArrayList<SqfwHouseholdRegistrationInfo>();
        List<SqfwHouseholdRegistrationInfo> houseInsertLog = new ArrayList<SqfwHouseholdRegistrationInfo>();
        // 解析导入文件
        boolean exceptionFlag = false;
        long startTime = System.currentTimeMillis();
        SqfwInfoDataEasyExcelListener<SqfwPovertyMonitorImportVO> listener = new SqfwInfoDataEasyExcelListener<>();
        try {
            EasyExcel.read(file.getInputStream(), SqfwPovertyMonitorImportVO.class, listener).headRowNumber(2).sheet(0).doReadSync();
            List<SqfwPovertyMonitorImportVO> data = listener.getData();
            Sys_user sysUser = sysUserService.fetch(SecurityUtil.getUserId());
            if (StringUtils.isNotEmpty(district) && !CommonForAdminConstants.ZHISHU.equals(sysUser.getDistrict())) {
                // 检查区属是否正确
                List<SqfwPovertyMonitorImportVO> districts = data.stream().filter(e -> !district.equals(e.getDistrict())).collect(Collectors.toList());
                if (districts.size() > 0) {
                    exceptionFlag = true;
                    throw new AppException("仅支持本行政区域数据导入，请确认！");
                }
            }
            String userId = SecurityUtil.getUserId();
            int updateNum = 0;
            for (SqfwPovertyMonitorImportVO summaryBO : data) {
                SqfwHouseholdRegistrationInfo sqfwHouseholdRegistrationInfo = new SqfwHouseholdRegistrationInfo();
                BeanUtil.copyProperties(summaryBO, sqfwHouseholdRegistrationInfo);
                // 检查更更新或者新增
                Cnd cnd = Cnd.NEW();
                cnd.and(SqfwHouseholdRegistrationInfo::getHouseNumber, "=", sqfwHouseholdRegistrationInfo.getHouseNumber());
                SqfwHouseholdRegistrationInfo sourceData = sqfwHouseholdRegistrationInfoService.fetch(cnd);
                if (null != sourceData) {
                    houseUpdateLog.add(sourceData);// 原数据记录到日志
                    sqfwHouseholdRegistrationInfo.setId(sourceData.getId());
                    BeanUtil.copyProperties(sqfwHouseholdRegistrationInfo, sourceData);
                    sqfwHouseholdRegistrationInfo.setUpdateTime(LocalDateTime.now());
                    sqfwHouseholdRegistrationInfo.setUpdateId(SecurityUtil.getUserId());
                    sqfwHouseholdRegistrationInfo.setUpdateId(userId);
                    sqfwHouseholdRegistrationInfoService.updateIgnoreNull(sqfwHouseholdRegistrationInfo);
                    updateNum++;
                } else {
                    sqfwHouseholdRegistrationInfo.setCreateTime(LocalDateTime.now());
                    sqfwHouseholdRegistrationInfo.setCreateBy(SecurityUtil.getUserId());
                    sqfwHouseholdRegistrationInfo.setDeleted(false);
                    houseInsertLog.add(sqfwHouseholdRegistrationInfo);
                    sqfwHouseholdRegistrationInfoService.insert(sqfwHouseholdRegistrationInfo);
                }
            }
            int importNum = listener.getData().size();
            if (0 < importNum) {
                resStr = " 成功导入户信息数据 " + importNum + " 条";
                if (updateNum > 0) {
                    resStr = resStr + "，其中更新户信息数据 " + updateNum + " 条";
                }
                log.info("户信息导入日志：{} ", resStr);
            } else {
                resStr = "无户信息有效数据导入";
            }
        } catch (Exception e) {
            if (exceptionFlag) {
                throw new AppException("仅支持本行政区域数据导入，请确认！");
            }
            log.error("导入户信息异常： {}", e.getMessage());
        } finally {
            listener.clear();
        }
        // 记录日志
        sysLogService.insertUpdateLog(SecurityUtil.getUserId(), "更新户信息：" + JSONObject.toJSONString(houseUpdateLog)
                        + "新增户信息：" + JSONObject.toJSONString(houseInsertLog), "shequ.sqfw_household_registration_info",
                "PovertyMonitorForAdminService.importHouseInfo", "");
        return resStr;
    }

    /**
     * 导入人员信息
     *
     * @param file
     * @return
     */
    private String importPersonInfo(TempFile file, String district) {
        if (file.getSize() <= 0) {
            return "人员信息文件不能为空！";
        }
        if (!file.getFile().getName().endsWith(".xlsx")) {
            return "人员信息文件格式不正确！";
        }
        String resStr = "";
        List<PersonInfo> personUpdateLog = new ArrayList<PersonInfo>();
        List<PersonInfo> personInsertLog = new ArrayList<PersonInfo>();
        List<SqfwHouseholdRegistrationInfo> houseInsertLog = new ArrayList<SqfwHouseholdRegistrationInfo>();
        // 解析导入文件
        boolean exceptionFlag = false;
        long startTime = System.currentTimeMillis();
        SqfwInfoDataEasyExcelListener<SqfwPovertyMonitorImportVO> listener = new SqfwInfoDataEasyExcelListener<>();
        try {
            EasyExcel.read(file.getInputStream(), SqfwPovertyMonitorImportVO.class, listener).headRowNumber(2).sheet(0).doReadSync();
            List<SqfwPovertyMonitorImportVO> data = listener.getData();
            Sys_user sysUser = sysUserService.fetch(SecurityUtil.getUserId());
            if (StringUtils.isNotEmpty(district) && !CommonForAdminConstants.ZHISHU.equals(sysUser.getDistrict())) {
                // 检查区属是否正确
                List<SqfwPovertyMonitorImportVO> districts = data.stream().filter(e -> !district.equals(e.getDistrict())).collect(Collectors.toList());
                if (districts.size() > 0) {
                    exceptionFlag = true;
                    throw new AppException("仅支持本行政区域数据导入，请确认！");
                }
            }
            String userId = SecurityUtil.getUserId();
            int updateNum = 0;
            for (SqfwPovertyMonitorImportVO summaryBO : data) {
                PersonInfo personInfo = new PersonInfo();
                BeanUtil.copyProperties(summaryBO, personInfo);
                // 通过户编号检查户信息表中是否存在，不存在则新增一条户记录
                SqfwHouseholdRegistrationInfo houseInfo = sqfwHouseholdRegistrationInfoService.fetch(
                        Cnd.where("house_number", "=", personInfo.getHouseHoldNumber())
                                .and("province", "=", personInfo.getProvince())
                                .and("city", "=", personInfo.getCity())
                                .and("district", "=", personInfo.getDistrict())
                                .and("county", "=", personInfo.getCounty())
                                .and("community", "=", personInfo.getCommunity()));
                if (null == houseInfo) {
                    SqfwHouseholdRegistrationInfo sqfwHouseholdRegistrationInfo = new SqfwHouseholdRegistrationInfo();
                    sqfwHouseholdRegistrationInfo.setProvince(personInfo.getProvince());
                    sqfwHouseholdRegistrationInfo.setCity(personInfo.getCity());
                    sqfwHouseholdRegistrationInfo.setDistrict(personInfo.getDistrict());
                    sqfwHouseholdRegistrationInfo.setCounty(personInfo.getCounty());
                    sqfwHouseholdRegistrationInfo.setCommunity(personInfo.getCommunity());
                    sqfwHouseholdRegistrationInfo.setHouseNumber(personInfo.getHouseHoldNumber());
                    sqfwHouseholdRegistrationInfo.setHouseholdHead(personInfo.getName());
                    sqfwHouseholdRegistrationInfo.setHouseholdHeadCard(personInfo.getIdNumber());
                    sqfwHouseholdRegistrationInfo.setCreateTime(LocalDateTime.now());
                    sqfwHouseholdRegistrationInfo.setCreateBy(SecurityUtil.getUserId());
                    sqfwHouseholdRegistrationInfo.setDeleted(false);
                    sqfwHouseholdRegistrationInfoService.insert(sqfwHouseholdRegistrationInfo);
                    houseInsertLog.add(sqfwHouseholdRegistrationInfo);
                }
                // 检查更更新或者新增
                Cnd cnd = Cnd.NEW();
                cnd.and(PersonInfo::getIdNumber, "=", personInfo.getIdNumber())
                        .and(PersonInfo::getBusinessType, "=", "脱贫人员");
                PersonInfo sourceData = personInfoService.fetch(cnd);
                if (null != sourceData) {
                    personUpdateLog.add(sourceData);// 原数据记录到日志
                    personInfo.setId(sourceData.getId());
                    BeanUtil.copyProperties(personInfo, sourceData);
                    personInfo.setUpdateDate(LocalDateTime.now());
                    personInfo.setUpdateBy(SecurityUtil.getUserId());
                    personInfo.setRemark("导入更新数据");
                    personInfoService.updateIgnoreNull(personInfo);
                    updateNum++;
                } else {
                    personInfo.setCreateDate(LocalDateTime.now());
                    personInfo.setCreateBy(SecurityUtil.getUserId());
                    personInfo.setBusinessType("脱贫人员");
                    personInfo.setRemark("导入插入数据");
                    personInfo.setLatestStatus("1");// 默认状态-正常
                    personInfo.setHouseholdId(houseInfo.getId());
                    personInfo.setDeleted(false);
                    personInsertLog.add(personInfo);
                    personInfoService.insert(personInfo);
                }
            }
            int importNum = listener.getData().size();
            if (0 < importNum) {
                resStr = " 成功导入人员数据 " + importNum + " 条";
                if (updateNum > 0) {
                    resStr = resStr + "，其中更新人员数据 " + updateNum + " 条";
                }
                log.info("人员导入日志：{} ", resStr);
            } else {
                resStr = "无有效人员数据导入";
            }
        } catch (Exception e) {
            if (exceptionFlag) {
                throw new AppException("仅支持本行政区域数据导入，请确认！");
            }
            log.error("导入人员信息异常： {}", e.getMessage());
        } finally {
            listener.clear();
        }
        // 记录日志
        sysLogService.insertUpdateLog(SecurityUtil.getUserId(), "更新人员信息：" + JSONObject.toJSONString(personUpdateLog)
                        + "新增人员信息：" + JSONObject.toJSONString(personInsertLog), "shequ.sqfw_person_info",
                "PovertyMonitorForAdminService.importPersonInfo", "");
        return resStr;
    }
}

